#ifndef PAGE_CACHE_HH
#define PAGE_CACHE_HH

#include "Common.h"
#include "PageMap.h"

class PageCache
{
public:
    static PageCache &getInstance();
    Span *newSpan(size_t nPage);
    mutex &getMtx();

    Span *pageIdSpanMap(PAGE_ID pageId);
    void dealloc(Span *span);

private:
    SpanList _pageSpanList[NPAGES];
    static PageCache _inst;
    mutex _mtx;
    // unordered_map<PAGE_ID, Span *> _pageIdSpanMap;
    TCMalloc_Map2<36> _pageIdSpanMap;
    ObjectPool<Span> _spanPool;
};

#endif